<template>
   <el-dialog :title="title" :visible.sync="showDlg" width="960px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="指标内容" prop="quotaDescription">
              <el-input v-model.trim="form.quotaDescription" placeholder="请输入指标内容" maxlength="207"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大分值" prop="maxScore">
              <el-input v-model.trim="form.maxScore" placeholder="请输入最大分值" maxlength="10"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="指标分类" prop="quotaClassify">
              <el-select v-model="form.quotaClassify" placeholder="请选择指标分类" style="width: 100%;">
                <el-option
                  v-for="dict in dict.type.indicator_classify"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <!-- <el-col :span="12">
            <el-form-item label="指标类别" prop="quotaType">
              <el-select v-model="form.quotaType" placeholder="请选择指标类别" style="width: 100%;">
                <el-option
                  v-for="dict in dict.type.indicator_category"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->

          <el-col :span="12">
            <el-form-item label="指标状态" prop="useStatus">
              <el-select v-model="form.useStatus" placeholder="请选择指标状态" style="width: 100%;">
                <el-option
                  v-for="dict in dict.type.indicator_state"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <!-- <el-col :span="12">
            <el-form-item label="指标类型" prop="scoreType">
              <el-select v-model="form.scoreType" placeholder="请选择指标类型" style="width: 100%;">
                <el-option
                  v-for="dict in dict.type.indicator_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
         
          <el-col :span="24">
            <el-form-item label="备注">
                <el-input
                    type="textarea"
                    :rows="3"
                    placeholder="请输入备注"
                    v-model="form.remark">
                </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="showDlg = false">取 消</el-button>
      </div>
    </el-dialog>
</template>

<script>
import { 
    addEvaluate,
    editEvaluate
} from "@/api/assessmentCenter/evaluationIndex";
export default {
    name: 'evaluationAdd',
    dicts: [
      "indicator_classify",
      // "indicator_category",
      "indicator_state",
      // "indicator_type"
      ],
    data () {
        return {
            showDlg: false,
            title: '添加',
            form: {
                quotaDescription: '',
                maxScore: 1,
                quotaClassify: '',
                // quotaType: '',
                useStatus: '',
                // scoreType: '',
                remark: ''
            },
            rules: {
                quotaDescription: [
                    { required: true, message: "请输入指标内容", trigger: "blur" }
                ],
                maxScore: [
                    { required: true, message: "请输入最大分值", trigger: "blur" }
                ],
                quotaClassify: [
                    { required: true, message: "请选择指标类别", trigger: "change" }
                ],
                // quotaType: [
                //     { required: true, message: "请选择指标类别", trigger: "change" }
                // ],
                useStatus: [
                    { required: true, message: "请选择指标状态", trigger: "change" }
                ],
                // scoreType: [
                //     { required: true, message: "请选择指标类型", trigger: "change" }
                // ],
            },
        }
    },
    methods:{
        open (rowData) {
            if (rowData) {
                this.title = '修改'
                this.form = rowData
            } else {
                this.title = '新增'
                this.form = {
                    quotaDescription: '',
                    maxScore: 1,
                    quotaClassify: '',
                    // quotaType: '',
                    useStatus: '',
                    // scoreType: '',
                    remark: ''
                }
            }
            this.showDlg = true
        },
        /** 提交按钮 */
        submitForm: function() {
            this.$refs["form"].validate(valid => {
                if (valid) {
                if (this.form.quotaId != undefined) {
                    editEvaluate({
                    ...this.form,
                    }).then(response => {
                        this.$modal.msgSuccess("修改成功");
                        this.showDlg = false;
                        this.$emit('updateList');
                    });
                } else {
                    addEvaluate({
                    ...this.form,
                    }).then(response => {
                        this.$modal.msgSuccess("新增成功");
                        this.showDlg = false;
                        this.$emit('updateList');
                    });
                }
                }
            });
        },
    }
}
</script>

<style>

</style>